<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>gsystem-系统安装</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layuimini/lib/layui-v2.5.5/css/layui.css}"
          href="../../../static/layuimini/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/css/public.css}" href="../../../static/layuimini/css/public.css"
          media="all">
</head>
</head>
<body>
<div class="layuimini-container" style="width: 1024px;margin: 0 auto;">
    <div class="layuimini-main" >

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>数据库设置</legend>
        </fieldset>
        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">数据库主机</label>
                <div class="layui-input-block">
                    <input type="text" name="dbHost" lay-verify="required" lay-reqtext="数据库主机不能为空"
                           placeholder="请输入数据库主机" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">数据库端口</label>
                <div class="layui-input-block">
                    <input type="text" name="dbPort" lay-verify="required" lay-reqtext="数据库端口不能为空"
                           placeholder="请输入数据库端口" value="3306" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">用户名称</label>
                <div class="layui-input-block">
                    <input type="text" name="dbUser" lay-verify="required" lay-reqtext="用户名称不能为空"
                           placeholder="请输入用户名称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">用户密码</label>
                <div class="layui-input-block">
                    <input type="text" name="dbPassword" lay-verify="required" lay-reqtext="用户密码不能为空"
                           placeholder="请输入用户密码" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">数据库名称</label>
                <div class="layui-input-block">
                    <input type="text" name="dbName" lay-verify="required" lay-reqtext="数据库名称不能为空"
                           placeholder="请输入数据库名称" value="" class="layui-input">
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>网站信息设置</legend>
            </fieldset>
            <div class="layui-form-item">
                <label class="layui-form-label required">网站名称</label>
                <div class="layui-input-block">
                    <input type="text" name="siteName" lay-verify="required" lay-reqtext="网站名称不能为空"
                           placeholder="请输入网站名称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">网站域名</label>
                <div class="layui-input-block">
                    <input type="text" name="domain" lay-verify="required" lay-reqtext="网站域名不能为空" placeholder="请输入网站域名"
                           value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">管理员名称</label>
                <div class="layui-input-block">
                    <input type="text" name="manageShowName" lay-verify="required" lay-reqtext="管理员名称不能为空"
                           placeholder="请输入管理员名称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">管理员账号</label>
                <div class="layui-input-block">
                    <input type="text" name="manageUsername" lay-verify="required" lay-reqtext="管理员账号不能为空"
                           placeholder="请输入管理员账号" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">管理员密码</label>
                <div class="layui-input-block">
                    <input type="text" name="managePassword" lay-verify="required" lay-reqtext="管理员密码不能为空"
                           placeholder="请输入管理员密码" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/layuimini/lib/layui-v2.5.5/layui.js}" src="../../../static/layuimini/lib/layui-v2.5.5/layui.js"
        charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$,
            form = layui.form;

        form.on('submit(setting)', function (data) {
            console.log(data.field);
            layer.load(2);
            $.ajax({
                type: 'post',
                url: '[[@{/}]]install/doInstall',
                data: data.field,
                dataType: 'json',
                success: function (result) {
                    console.log(result);
                    if (result.success){
                        layer.msg("安装成功，3秒后跳转至首页");
                        setTimeout(function () {
                            location.reload();
                        },3000);
                    }else{
                        layer.msg(result.msg);
                    }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    layer.msg(textStatus);
                },
                complete: function () {
                    layer.closeAll('loading');
                }
            });
            return false;
        });

    })
</script>
</body>
</html>